/*
 * Class Organ.java
 * 9.06.2012
 * 
 * Abstract class which represents basic characteristics of 
 * human organ (like organ health).
 */

package human;

/**
 * Basic class of human organ.
 * It has only common for all organs characteristics and methods.
 * 
 * @author Vasyl Khyzhniak
 * @version 1.0
 */
public abstract class Organ {
	protected int health;						//from -100(death) to +100(newborn)
	protected boolean isNecessaryForLife;		//is the organ necessary for being alive
	protected int upperLimit;					//upper limit of organ characteristics
	protected int lowerLimit;					//lower limit of organ characteristics
	
	/**
	 * Replaces organ health with new value
	 * @param value Defines the new value of health
	 * @author Vasyl Khyzhniak
	 */
	public void changeHealth(int value) {			
		if (this.health + value > this.upperLimit){				//keeps value in limit [-100,100]
			this.health = this.upperLimit;
		} else if (this.health + value < this.lowerLimit) {
			this.health = this.lowerLimit;
		} else {
			this.health += value;
		}
	}
	
	/**
	 * Returns value of organ health
	 * @return Current health value of organ
	 * @author Vasyl Khyzhniak
	 */
	public int getHealth() {
		return this.health;
	}

	/**
	 * Returns value which indicates can human live 
	 * without this organ or no.
	 * There is no "set" method because this parameter
	 * could not be changed.
	 * @return true if organ is necessary for being alive
	 * @author Vasyl Khyzhniak
	 */
	public boolean getLifeImportance() {
		return this.isNecessaryForLife;		
	}

	public int getUpperLimit() {
		return upperLimit;
	}

	public int getLowerLimit() {
		return lowerLimit;
	}
	
}
